home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-23 | 3.3 KB | 141 lines | [TEXT/PJMM] |
- unit MySystem7;
- { DeHQX v2.0.0 © Peter Lewis, Aug 1991 }
-
- interface
-
- uses
- Types, OSUtils, Files, AppleTalk, Aliases, PPCToolBox, Processes, EPPC, Notification, AppleEvents, MyUtilities, MyNotifier, Folders;
- {Note: InitUtilities must be called prior to using functions in this file }
- { (It is normally called by InitMainLoop in MyMainLoop.unit) }
-
- function MyResolveAliasFile (var vrn: integer; var dirID: longInt; var fname: str63): OSErr;
- function MyFindFolder (vrn: INTEGER; folder: OSType; var ovrn: INTEGER; var oDirID: LONGINT): OSErr;
- function MyInteractWithUser (idleproc: Ptr): OSErr;
- function MyGetAPPL (sig: OSType; var vrn: integer; var dirID: longInt; var fname: str63): OSErr;
-
- implementation
-
- const
- pref_folder = 'Preferences';
-
- function MyResolveAliasFile (var vrn: integer; var dirID: longInt; var fname: str63): OSErr;
- var
- fs: FSSpec;
- isfolder, wasalias: boolean;
- oe: OSErr;
- begin
- if system7 then begin
- with fs do begin
- vRefNum := vrn;
- parID := dirID;
- name := fname;
- oe := ResolveAliasFile(fs, true, isfolder, wasalias);
- if oe = noErr then begin
- vrn := vRefNum;
- dirID := parID;
- fname := name;
- end;
- end;
- end
- else
- oe := noErr;
- MyResolveAliasFile := oe;
- end;
-
- function MyFindFolder (vrn: INTEGER; folder: OSType; var ovrn: INTEGER; var oDirID: LONGINT): OSErr;
- var
- oe: OSErr;
- name: str255;
- prefDirID: longInt;
- pb: HParamBlockRec;
- begin
- if system7 then begin
- oe := FindFolder(vrn, folder, true, ovrn, oDirID);
- end
- else begin
- oe := GetDirID(sysenv.sysVRefNum, ovrn, oDirID);
- if (oe = noErr) and (folder = kPreferencesFolderType) then begin
- name := pref_folder;
- oe := DirCreate(ovrn, oDirID, name, prefDirID);
- if oe = noErr then
- oDirID := prefDirID
- else begin
- with pb do begin
- ioNamePtr := @name;
- ioVRefNum := ovrn;
- ioDirID := oDirID;
- ioFDirIndex := 0;
- end;
- oe := PBGetCatInfo(@pb, false);
- if oe = noErr then
- oDirID := pb.ioDirID;
- end;
- oe := noErr;
- end;
- end;
- MyFindFolder := oe;
- end;
-
- function MyInteractWithUser (idleproc: Ptr): OSErr;
- var
- oe: OSErr;
- begin
- if system7 then
- oe := AEInteractWithUser(maxLongInt, nil, idleproc)
- else begin
- if in_foreground then
- MyInteractWithUser := noErr
- else begin
- Notify(true, true, 128, 0, 0, 0);
- { Should wait til we are in the foreground, but its too messy }
- end;
- end;
- end;
-
- function MyGetAPPL (sig: OSType; var vrn: integer; var dirID: longInt; var fname: str63): OSErr;
- var
- i: integer;
- pbdt: DTPBRec;
- crdate: longInt;
- oe: OSErr;
- found: boolean;
- begin
- found := false;
- if system7 then begin
- i := 1;
- repeat
- vrn := 0;
- oe := GetVolInfo(fname, vrn, i, crdate);
- i := i + 1;
- if oe = noErr then begin
- with pbdt do begin
- fname := '';
- ioNamePtr := @fname;
- ioVRefNum := vrn;
- oe := PBDTGetPath(@pbdt);
- if oe = noErr then begin
- ioIndex := 0;
- ioFileCreator := sig;
- oe := PBDTGetAPPLSync(@pbdt);
- if oe = noErr then
- found := true;
- end;
- end;
- oe := noErr;
- end;
- until found or (oe <> noErr);
- end;
- if found then begin
- oe := noErr;
- dirID := pbdt.ioAPPLParID;
- end
- else begin
- oe := afpItemNotFound;
- vrn := 0;
- dirID := 2;
- fname := '';
- end;
- MyGetAPPL := oe;
- end;
-
- end.